package day16.feifei.homework;

import java.io.File;

public class FileList {

    public static void getSomthing1(File[] files,int count) {
        for(int i=1;i<=count;i++){
            System.out.print("--");
        }
        for (File file1 : files) {

            if (file1.isDirectory()) {
                System.out.println("[目录] " + file1.getName());
                getSomthing1(file1.listFiles(),count+1);
            } else {
                System.out.println("[文件] " + file1.getName());
            }
        }
    }

    public static void readContentslnDirectoryRecursive(String path) {
        File file = new File(path);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isDirectory()) {
                System.out.println("[目录] " + file1.getName());
                getSomthing1(file1.listFiles(),1);
            } else {
                System.out.println("[文件] " + file1.getName());
            }
        }
    }

    public static void main(String[] args) {
        File file = new File("D:\\file\\book\\cc");
        String path = file.getPath();

        readContentslnDirectoryRecursive(path);
    }
    }
